package commands.player

import utils.GenericSyntaxParser

import static utils.WordUtils.*
import static org.groovymud.utils.MessengerUtils.sendMessageToRoom
def all = false
def itemName = argstr

GenericSyntaxParser parser = new GenericSyntaxParser()
parser.parse(argstr, " ")

def itemsToGet = parser.subjectObject.findObjectInContainer(source)

stream = source.getTerminalOutput()

if(itemsToGet instanceof Set){
	def copy = new HashSet(itemsToGet)
	copy.each{
		hashSet -> 
			hashSet.each{
				item ->
					source.getCurrentContainer().addMudObject(item)
					sendDropMessage(item);
			}
	}
}else{
	if(itemsToGet != null){
	    source.getCurrentContainer().addMudObject(itemsToGet)	
	    sendDropMessage(itemsToGet)
	}else{
	    stream.writeln("Cannot find ${itemName} to drop.")
	}
}

def sendDropMessage(item){
	def scopeMsg = "${source.getName()} drops ${affixIndefiniteArticle(item)}"
	def sourceMsg = "You drop ${affixIndefiniteArticle(item)}"
	sendMessageToRoom(source, sourceMsg, scopeMsg);
}